<template>
    <div class="addProject business-workAdd">
        <div class="addForm zll-form">
			<el-form :model="addForm" :rules="rules" ref="addForm" class="demo-ruleForm">
                <el-row :gutter="40">
                    <el-col :span="12">
                        <el-form-item class="formList" prop="fdType" label="违章类型：">
                            <el-select clearable class="input_right" v-model="addForm.fdType" disabled>
								<el-option label="安全纪律" value="0"></el-option>
								<el-option label="质量内控" value="1"></el-option>
								<el-option label="客户投诉" value="2"></el-option>
								<el-option label="仓储规范" value="3"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item class="formList" prop="fdDate" label="违章日期：">
                            <el-date-picker clearable class="input_right"  v-model="addForm.fdDate" disabled type="date"></el-date-picker>
                        </el-form-item>
                        <el-form-item class="formList" prop="fdViolatorId" label="违章人：">
<!--                            <el-input clearable class="input_right"  v-model="addForm.fdViolatorId" disabled ></el-input>-->
							<el-select clearable v-model="addForm.fdViolatorId" placeholder="违章人" disabled>
								<el-option v-for="item in employees" :key="item.id" :label="item.employeeName" :value="item.id"></el-option>
							</el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item class="formList" prop="fdStatus" label="罚单状态：">
                            <el-select clearable class="input_right" v-model="addForm.fdStatus" disabled>
								<el-option label="待审批" value="0"></el-option>
								<el-option label="已审批" value="1"></el-option>
								<el-option label="已拒绝" value="2"></el-option>
								<el-option label="已作废" value="3"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item class="formList" prop="fdCode" label="罚单号：">
                            <el-input clearable class="input_right"  v-model="addForm.fdCode" disabled></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-form-item class="formList" prop="fdReason" label="违章事由：">
                    <el-input clearable class="input_right"  v-model="addForm.fdReason" disabled :rows="2" maxlength="50" show-word-limit></el-input>
                </el-form-item>
                <el-row :gutter="40">
                    <el-col :span="12">
                        <el-form-item class="formList" prop="fdMoney" label="处罚金额(元)：">
                            <el-input clearable class="input_right"  v-model="addForm.fdMoney" disabled ></el-input>
                        </el-form-item>
                        <el-form-item class="formList" prop="data8" label="开单人：">
                            <el-input clearable class="input_right"  v-model="addForm.createrName" disabled ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item class="formList"></el-form-item>
                        <el-form-item class="formList" prop="data9" label="审批人：" v-if="type !== 'add'">
                            <el-input clearable class="input_right"  v-model="addForm.approvedName" disabled ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </div>
    </div>
</template>
<script>
export default {
    props: ['editData','type','employeeList'],
    data(){
        return {
			addForm: {
				id: '',
				fdType: '',
				fdCode:'',
				fdDate:'',
				fdStatus:'',
				fdViolatorId: '',
				fdReason:'',
				fdMoney:'',
				createrName:'',
				approvedName:'',
			},

			employees: [],
			count:0,

			rules: {
				fdType: [
					{required: true, message: '请选择违章类型', trigger: 'change'},
				],
				fdDate: [
					{required: true, message: '请选择违章日期', trigger: 'change'},
				],
				fdViolatorId: [
					{required: true, message: '请输入违章人', trigger: 'blur'},
				],
				fdStatus: [
					{required: true, message: '请选择罚单状态', trigger: 'change'},
				],
				fdReason: [
					{required: true, message: '请输入违章事由', trigger: 'blur'},
				],
				fdMoney: [
					{required: true, message: '请输入处罚金额', trigger: 'blur'},
				],
			}
        }
    },
    methods: {
		submitForm(val,type) {
			let self = this;
            self.$refs['addForm'].validate((valid) => {
                if (valid) {
                    self.$eventBus.$emit("updateWorkList");
                } else {
                    return false;
                }
            });
		},
    },
    mounted(){
        
    },

	watch: {
		editData(val) {

			this.employees = JSON.parse(JSON.stringify(this.employeeList || []));

			if (Object.getOwnPropertyNames(val).length > 1){
				this.addForm.id = val.id;
				this.addForm.fdType = val.fdType;
				this.addForm.fdCode = val.fdCode;
				this.addForm.fdDate = val.fdDate;
				this.addForm.fdStatus = val.fdStatus;
				this.addForm.fdViolatorId = val.fdViolatorId;
				this.addForm.fdReason = val.fdReason;
				this.addForm.fdMoney = val.fdMoney;
				this.addForm.createrName = val.createrName;
				this.addForm.approvedName = val.approvedName;

			}

		}
	}
}
</script>
<style lang="scss" scoped>
@import "@/style/dialog.scss";
.formList {
    height: 32px;
}
</style>